package com.saw01;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Scanner;

public class CollecttionStudentDemo {
    public static void main(String[] args) {
        Collection<Student> c = new ArrayList<Student>();

//        创建学生对象
        Student s1 = new Student("小爱同学", 26);
        Student s2 = new Student("小王同学", 27);
        Student s3 = new Student("小史同学", 28);
//   向学生集合里面添加学生对象
        c.add(s1);
        c.add(s2);
        c.add(s3);

        Iterator<Student> it = c.iterator();

//        遍历集合输出对象中的属性
        while (it.hasNext()){
            Student s = it.next();
            System.out.println(s.getName() + "," + s.getAge());
        }
    }
}
